package com.chen.string.stringjoiner;

import java.util.StringJoiner;

public class StringJoinerDemo2 {
    public static void main(String[] args) {
        StringJoiner sj = new StringJoiner(",", "[", "]"); // 间隔，前缀，后缀

        // 添加元素
        sj.add("1").add("2");

        int length = sj.length();
        System.out.println(length);

        // 打印结果
        System.out.println(sj);

        String s1 = sj.toString();
        System.out.println(s1);
    }
}
